#include <stdio.h>
#include <malloc.h>
#include <stdbool.h>

#define MAXSIZE 100
typedef struct TreeNode *BinTree;
typedef int ElementType;
typedef BinTree Position;
typedef struct BStack *Stack;
struct TreeNode {
    ElementType data;
    BinTree left;
    BinTree right;
};
struct BStack {
    BinTree data[MAXSIZE];
    int top;
};
Stack CreateStack() {
    Stack  stack;
    stack = (Stack)malloc(sizeof (struct BStack));
    stack->top = -1;
    return stack;
}
bool isFull(Stack BS) {
    return (BS->top == MAXSIZE);
}
void push(Stack BS,BinTree BT) {
    if(isFull(BS)) {
        printf("堆栈满!\n");
        return;
    }
    BS->top++;
    BS->data[BS->top] = BT;
    return;
}
bool isEmpty(Stack BS) {
    return (BS->top == -1);
}
BinTree pop(Stack BS) {
    if (isEmpty(BS)) {
        printf("堆栈空!\n");
        return NULL;
    }

    return BS->data[BS->top--];
}
void PreOrderTraversal(BinTree BT) {
    if(BT) {
        printf("%d",BT->data);
        PreOrderTraversal(BT->left);
        PreOrderTraversal(BT->right);
    }
}
void InOrderTraversal(BinTree BT) {
    BinTree T = BT;
    Stack S = CreateStack();
    while (T || !isEmpty(S)) {
        while (T) {
            push(S,T);
            T = T->left;
        }
        if(!isEmpty(S)) {
            T = pop(S);
            printf("%5d",T->data);
            T = T->right;

        }
    }

}


int main() {

    return 0;
}
